package j03stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;

public class J1 {
    public static void main(String[] args) {
        ArrayList<Integer> arr = new ArrayList<>();
        Collections.addAll(arr,23,45,66,88,99,55,11);
        //流
        Stream<Integer> s1 = arr.stream();
        System.out.println("s1 = " + s1);


//        System.out.println("count="+s1.count());
//        s1.forEach(el->{
//            System.out.println(el);
//        });
        //偶数
        System.out.println("======");
//        Stream s2 = s1.filter(el->false);
//        Stream s2 = s1.filter(el->true);
        Stream s2 = s1.filter(el->el%2==0?true:false);
        s2.forEach(el-> System.out.println(el));

        System.out.println("==简写==");
        arr.stream().filter(el->el%2==0).forEach(el-> System.out.println(el));
    }
}
